program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  x0, y0, x1, y1, x2, y2, a, b, c : integer;
  xp, yp, d, d1, d2 : real;
  fin : textfile;
begin
  assignfile (fin, 'input.txt');
  reset(fin);

  writeln('The distance between the point and the ray is:');
  read (fin, x0);
  readln(fin, y0);
  read (fin, x1);
  readln(fin, y1);
  read (fin, x2);
  readln(fin, y2);

  a:=y1-y2;
  b:=x2-x1;
  c:=x1*y2-x2*y1;
  d:= (abs(a*x0+b*y0+c))/sqrt(a*a+b*b);

  xp:=x0-(a*d/sqrt(a*a+b*b));
  yp:=y0-(b*d/sqrt(a*a+b*b));

  if ((x2-xp)*(x1-xp)<=0) or ((y2-yp)*(y1-yp)<=0) then
  begin
    d1:=sqrt(sqr(xp-x1)+sqr(yp-y1));
    d2:=sqrt(sqr(xp-x2)+sqr(yp-y2));
    if (d1<d2) then
      writeln(d1:0:5);
    if (d2<d1) then
      writeln(d2:0:5);
  end;

  if ((x2-xp)*(x1-xp)>0) and ((y2-yp)*(y1-yp)>0) then
  begin
    writeln(d:0:5);
  end;
  closefile(fin);
  readln;
end.
